import api from './index'

export const authAPI = {
  // 用户登录
  login(credentials) {
    return api.post('/auth/login/', credentials)
  },

  // 用户注册
  register: (userData) => {
    return api.post('/auth/register/', userData)
  },

  // 用户登出
  logout(refreshToken) {
    return api.post('/auth/logout/', { refresh_token: refreshToken })
  },

  // 获取用户名建议
  getUserSuggestions() {
    return api.get('/auth/user-suggestions/')
  },

  // 获取用户信息
  getUserProfile() {
    return api.get('/auth/profile/')
  },

  // 更新用户信息
  updateProfile(profileData) {
    return api.put('/auth/profile/', profileData)
  },

  // 修改密码
  changePassword(passwordData) {
    return api.post('/auth/change-password/', passwordData)
  },

  // 上传头像
  uploadAvatar(formData) {
    return api.post('/auth/upload-avatar/', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  }
}
